package com.fjw.mapper;

import com.fjw.pojo.PostRecord;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PostRecordMapper {
    //新增
    @Insert("insert into PostRecord(cv_id,article_id,advice) values (#{cv_id},#{article_id},#{advice})")
    void add(PostRecord postRecord);

    //通过ID查找
    @Select("select * from PostRecord where id=#{id}")
    PostRecord findById(Integer id);

    //通过简历ID查找
    @Select("select * from PostRecord where cv_id=#{cv_id}")
    List<PostRecord> findByCv_id(Integer cv_id);

    //通过文章ID查找
    @Select("select * from PostRecord where article_id=#{article_id}")
    List<PostRecord> findByArticle_id(Integer article_id);

    //通过文章ID和简历ID联合查找
    @Select("select * from PostRecord where cv_id=#{cv_id} and article_id=#{article_id}")
    PostRecord findByCv_idAndArticle_id(Integer cv_id,Integer article_id);

    //通过ID更新advice
    @Update("update PostRecord set advice=#{advice} where id=#{id}")
    void updateById(Integer id,String advice);
}
